package com.yanjiali.config;

import com.yanjiali.constant.ESIndexConstant;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Package: com.yanjiali.config
 * @Author: yanjiali
 * @Created: 2025/4/17 21:19
 */
@Configuration
public class ESConfig {
    /**
     * 将客户端注册为bean
     * @return
     */
    @Bean
    public RestHighLevelClient client(){
        return  new RestHighLevelClient(RestClient.builder(
                HttpHost.create(ESIndexConstant.ES_SERVICE_ADDRESS)
        ));
    }
}
